<template>
	<view :style="[{paddingTop:CustomBar+'px'}]">
		<cu-custom bgColor="bg-colorP" :isBack="true">
			<block slot="backText"></block>
			<block slot="content">{{title}}</block>
		</cu-custom>
		<view class="agree" v-html="agreeText"></view>
	</view>
</template>

<script>
	import htmlParser from '@/utils/html-parser'
	export default {
		data() {
			return {
				CustomBar: this.CustomBar,
				agreeText: '',
				title: ''
			}
		},
		methods: {
			// 获取法律协议
			getFalv(){
				var that = this
				that.title = '法律声明'
				this.$request({
					url: '/Upgrade/get_law',
					success: res => {
						if (res.data.status == 1) {
							var jsonText = res.data.data.content
							var htmlString = jsonText.replace(/\\/g, "").replace(/<img/g, "<img style=\"width:100%;height:auto;\"");
							that.agreeText = htmlParser(htmlString);
							uni.hideLoading()
						}
					},
					fail: () => {},
					complete: () => {}
				});
			},
			// 获取用户须知
			getYonghu(){
				var that = this
				that.title = '用户须知'
				this.$request({
					url: '/Upgrade/get_user_notes',
					success: res => {
						if (res.data.status == 1) {
							var jsonText = res.data.data.content
							var htmlString = jsonText.replace(/\\/g, "").replace(/<img/g, "<img style=\"width:100%;height:auto;\"");
							htmlString = htmlString.replace(/[\r\n]/g,"");
							htmlString = htmlString.replace(/&nbsp;/g,"");
							that.agreeText = htmlParser(htmlString);
							uni.hideLoading()
						}
					},
					fail: () => {},
					complete: () => {}
				});
			},
			// 获取管理声明
			getGuanli(){
				var that = this
				that.title = '管理声明'
				this.$request({
					url: '/Upgrade/get_manage',
					success: res => {
						if (res.data.status == 1) {
							var jsonText = res.data.data.content
							var htmlString = jsonText.replace(/\\/g, "").replace(/<img/g, "<img style=\"width:100%;height:auto;\"");
							that.agreeText = htmlParser(htmlString);
							uni.hideLoading()
						}
					},
					fail: () => {},
					complete: () => {}
				});
			}
		},
		onLoad(options) {
			if (options.type == 'yonghu') {
				this.getYonghu()
			} else if(options.type == 'falv'){
				this.getFalv()
			}else if(options.type == 'guanli'){
				this.getGuanli()
			}
		}
	}
</script>

<style>
	page {
		background: #fff;
	}
	
	.agree {
		font-family: '微软雅黑';
		font-size: 28rpx !important;
		letter-spacing: 1rpx;
		color: #333333;
		padding: 0 24rpx;
		box-sizing: border-box;
	}
</style>
